package com.example.demolearn.jvm;

import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Opcodes;

public class OOMTest extends ClassLoader {
    public static void main(String[] args) {
         int j = 0;

        OOMTest oomTest = new OOMTest();


        for (int i=0;i<100000;i++){
            ClassWriter classWriter = new ClassWriter(0);
            classWriter.visit(Opcodes.V1_8,Opcodes.ACC_PUBLIC,"Class" + i,null,"java/lang/Object",null);
            classWriter.visitEnd();
            byte[] bytes = classWriter.toByteArray();

            oomTest.defineClass("Class"+ i ,bytes,0,bytes.length);

            j++;
        }

    }
}
